
{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block title %}我的博文{% endblock %}

{% block page_content %}

<div class="page-header">
    <!--{{ post.title }}-->
</div>
    <div>
        <!--{{ wtf.quick_form(form) }}-->
    </div>
    <div class="row">
        <div class="col-lg-9">
            <div class="row">
                <div class="col-lg-12"><h1>{{ post.title }}</h1></div>
            </div>
            <div class="row">
                <div class="col-lg-6">
                    <p>作者： <a href="{{ url_for('post_bpn.user', username=post.user.username) }}">{{ post.user.username }}</a> 写于 {{ post.publish_date }}</p>
                </div>
                <div class="col-lg-6">
                    <p class="text-right"> 标签: {% for tag in tags %}
                            <a href="{{ url_for('post_bpn.tag', tag_name=tag.title) }}">{{tag.title}}</a>
                        {% endfor %}
                    </p>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    {{ post.text | safe }}
                </div>
            </div>
            <div class="row">
                <h1>评论({{ comments | length }})</h1>
                <div class="col-lg-12">
                    <h3>新评论：</h3>
                    <form method="POST" action="{{ url_for('post_bpn.post', post_id=post.id) }}">
                        {{ form.hidden_tag() }}
                        <div class="form-group">
                            {{ form.name.label }}
                            {% if form.name.errors %}
                                {% for e in form.name.errors %}
                                    <p class="help-block">{{ e }}</p>
                                {% endfor %}
                            {% endif %}
                            {{ form.name(class_='form-control') }}
                        </div>
                        <div class="form-group">
                            {{ form.text.label }}
                            {% if form.text.errors %}
                                {% for e in form.text.errors %}
                                    <p class="help-block">{{ e }}</p>
                                {% endfor %}
                            {% endif %}
                            {{ form.text(class_='form-control') }}
                        </div>
                        <input class="btn btn-primary" type="submit" value="提交评论">
                    </form>
                </div>
                <div class="col-lg-12">
                    {% if comments | length == 0 %}
                    <p>这篇博文目前没有评论。</p>
                    {% else %}
                        {% for comment in comments %}
                            <div class="well">
                                <p>By: {{ comment.name }} on {{ comment.date }}</p>
                                <p>{{ comment.text }}</p>
                            </div>
                        {% endfor %}
                    {% endif %}
                </div>
            </div>
        </div>
        <div class="col-lg-3">
            <div class="row">
                <h5>最新博文</h5>
                <ul>
                    {% for post in recent %}
                        <li><a href="{{ url_for('post_bpn.post', post_id=post.id) }}">{{ post.title }}</a></li>
                    {% endfor %}
                </ul>
            </div>
            <div class="row">
                <h5>常见标签</h5>
                <ul>
                    {% for tag in top_tags %}
                        <li><a href="{{ url_for('post_bpn.tag', tag_name=tag[0].title) }}">{{ tag[0].title }}</a></li>
                    {% endfor %}
                </ul>
            </div>
        </div>
    </div>

{% endblock %}